using UnityEngine;

public class AnimationController : MonoBehaviour
{
    private Animator animator;
    void Awake()
    {
        animator = GetComponent<Animator>();
    }

    public void SetAnim(string state, float currentSpeed, float animationDistance, float animationLength)
    {
        AnimatorStateInfo currentState = animator.GetCurrentAnimatorStateInfo(0);

        if (!currentState.IsName(state))
        {
            animator.Play(state, -1);
            animator.speed = currentSpeed / (animationDistance / animationLength);
        }
    }
}